/*
 * timersdl.cpp
 *
 */

#include "timersdl.h"

Timer::Timer()
{
	startTicks_ = 0;
    pausedTicks_ = 0;
    paused_ = false;
    started_ = false;
}

Timer::~Timer()
{

}
void Timer::start()
{
    started_ = true;
    paused_ = false;

    /*Consegue o tempo do clock atual*/
    startTicks_ = SDL_GetTicks();
}

void Timer::stop()
{
    started_ = false;
    paused_ = false;
}
void Timer::unPause()
{
    if( paused_ == true )
    {
        paused_ = false;
        startTicks_ = SDL_GetTicks() - pausedTicks_;
        pausedTicks_ = 0;
    }
}

int Timer::getTicks()
{
    if( started_ == true )
    {
        if( paused_ == true )
        {
            return pausedTicks_;
        }
        else
        {
            return SDL_GetTicks() - startTicks_;
        }
    }
    return 0;
}

bool Timer::isStarted()
{
    return started_;
}

bool Timer::isPaused()
{
    return paused_;
}

